import request from '@/utils/request';
import { encrypt } from '@/utils/jsencrypr';

const baseURI = '/auth';

/**
 * 登录接口定义
 * @param {用户名和密码} params
 * @returns
 */
export const login = (params: API.ILoginParam) => {
  params.password = encrypt(params.password) ? (encrypt(params.password) as string) : '';
  return request({
    url: `${baseURI}/login`,
    headers: {
      hasToken: false,
    },
    method: 'POST',
    data: params,
  });
};

/**
 * 获取登录用户信息
 * @returns
 */
export const getInfo = () => {
  return request({
    url: `/system/user/getInfo`,
    method: 'GET',
  });
};

/**
 * 获取验证码
 */
export const getCode = () => {
  return request({
    url: `/code`,
    headers: {
      hasToken: false,
    },
  });
};
